# Contributor: tomasgroth at yahoo.dk

buildarch=4

pkgname="libcec-cubox"
pkgver=2.4.1
pkgrel=2
pkgdesc="Pulse-Eight's libcec for the Pulse-Eight USB-CEC adapter with support for cubox"
arch=('armv7h')
url="https://github.com/Pulse-Eight/libcec"
license=('GPL')
depends=('udev' 'lockdev')
makedepends=('linux-cubox-headers')
conflicts=('libcec')
provides=('libcec')
_commit=30d91946a284571ac9f56c5190ea78e279807a44
#source=("libcec-${pkgver}.tar.gz::https://github.com/Pulse-Eight/libcec/archive/${_commit}.tar.gz"
source=("libcec-${pkgver}.tar.gz::https://github.com/Pulse-Eight/libcec/archive/${_commit}.tar.gz"
        "99-libcec.rules")
sha256sums=('e4c0ef40d68130caf5c411c213a46f99d2897406b0492d2efba3a975a3bdf8c7'
            'fb4f721a9bd0e40253c71dc1827410c8c98853dcf2e8cf95a654feb60da8f5e6')

options=(!libtool)

build() {
  _kernel_release="$(pacman -Q linux-cubox-headers | grep -Eo "[^\ ]+$")-ARCH"

  cd "libcec-$_commit"
  export CFLAGS="$CFLAGS -fPIC"
  export CXXFLAGS="$CXXFLAGS -fPIC"
  export LDFLAGS="$LDFLAGS -fPIC"
  autoreconf -vif
  ./configure --prefix=/usr --enable-cubox \
    --with-tda995x-toolkit-path="/usr/src/linux-${_kernel_release}/include/nxp_hdmi"
  make
}

package() {
  cd "libcec-$_commit"
  make DESTDIR="$pkgdir" install
  install -D -m0644 "${srcdir}/99-libcec.rules" "${pkgdir}/etc/udev/rules.d/99-libcec.rules"
}

